//
// Created by jackson on 2020/10/4.
//
#include "thread_binder.h"

#ifdef LINUX
#include <pthread.h>
#include <errno.h>

long CThreadBinder::MakeThread(unsigned long *thread_id, void* (* start_address)(void*), void* arg)
{
    long result = pthread_create(thread_id, NULL, start_address, arg);
    return result;
}

long CThreadBinder::WaitFor(unsigned long thread_id)
{
    long result;
    void* p = &result;
    pthread_join(thread_id, &p);
    return result;
}

void CThreadBinder::ExitFromThread(unsigned long result)
{
    pthread_exit((void*)result);
}
void CThreadBinder::CleanThread(unsigned long thread_id)
{
    pthread_detach(thread_id);
}
#endif